package oktx.feign.terminator;

import oktx.terminator.TransactionTerminatorBean;
import oktx.config.LocalTxTerminator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by huangdachao on 2018/5/30 15:28.
 */
@RestController
@RequestMapping("/tx")
public class RestTxTerminatorService implements TransactionTerminatorBean {
    @Autowired LocalTxTerminator terminator;

    @Override
    @RequestMapping("/commit")
    public void commit(@RequestParam("xid") String xid) {
        terminator.commit(xid, false);
    }

    @Override
    @RequestMapping("/rollback")
    public void rollback(@RequestParam("xid") String xid) {
        terminator.rollback(xid, false);
    }
}
